<?php

require_once '../utils/SqlHelper.class.php';
class PagerService {
	/**
	 * 获取用户列表
	 * @param unknown_type $page
	 */
	function getUserPage($page) {
		$sqlHelper = new SqlHelper ();
			$sql = "select * from j_tab_user order by id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	
	function getModelPage($page, $type){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from j_tab_model where type=$type order by id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getTelPage($page,$fatherid){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from j_tab_tel where fatherid=".$fatherid." order by id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getNextPage($page,$fatherid){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from j_tab_next where fatherid=".$fatherid." order by id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getFristPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from j_tab_frist order by id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getXuexiPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from j_tab_xuexi order by id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getKefuPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from j_tab_kefu order by id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	/**
	 * 获取反馈意见
	 * @param unknown_type $page
	 */
	function getFeedBackPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_feedback limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	/**
	 * 分类管理
	 * @param unknown_type $page
	 */
	function getTypePage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_type limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	
	
	function getSecondTypePage($page,$id){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_type where fatherId=$id limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	
	
	function getPositionPage($isnouse, $page, $areaCount, $key){
		$sqlHelper = new SqlHelper ();
		if($areaCount == 0){
			if($key== ""){
				$sql = "select * from tab_usersend where isnouse=$isnouse order by isjingjia desc,iszhiding desc,time desc limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
			}else{
				$sql = "select * from tab_usersend where isnouse=$isnouse and title like '%".$key."%' order by isjingjia desc,iszhiding desc,time desc limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
			}
		}else{
			if($key== ""){
				$sql = "select * from tab_usersend where isnouse=$isnouse and areaCount=".$areaCount." order by isjingjia desc,iszhiding desc,time desc limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
			}else{
				$sql = "select * from tab_usersend where isnouse=$isnouse and title like '%".$key."%' and areaCount=".$areaCount." order by isjingjia desc,iszhiding desc,time desc limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
			}
			
		}
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getJubaoPage($page,$key){
		$sqlHelper = new SqlHelper ();
		if($key == ""){
			$sql = "select * from tab_jubao order by time desc limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		}else{
			$sql = "select * from tab_jubao where content like '%".$key."%' order by time desc limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		}
		
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	/**
	 * 获取角色权限
	 * @param unknown_type $page
	 */
	function getRoleAuthPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_user where sysLenver>0 limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	
	function getAreaPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_area where fatherid != -1 limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	
	function getIndexPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_index limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	
	function getLifePage($page, $userarea){
		$sqlHelper = new SqlHelper ();
		if($userarea == 0){
			$sql = "select * from tab_life limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		}else{
			$sql = "select * from tab_life where area=".$userarea." limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		}
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getLocalPayPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_payaddress limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
	function getTaobaoPage($page){
		$sqlHelper = new SqlHelper ();
		$sql = "select * from tab_taobao_link limit " . ($page->pageNow - 1) * $page->pageSize . "," . $page->pageSize;
		$sqlHelper->query_page ( $sql, $page );
		$sqlHelper->close_connect ();
	}
}
?>